﻿Public Class frmSaveFile
    Public Result As Boolean = False
    Public Path As String = ""
    Public FileName As String = ""
    Public FileType As String = ""
    Private Sub frmSaveFile_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            Me.BackColor = Color.FromArgb(194, 217, 247)
            lblFileType.Text = FileType
        Catch ex As Exception

        End Try
    End Sub
    Private Sub cmdOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOpen.Click
        Try
            Folder.ShowDialog()
            txtPath.Text = Folder.SelectedPath
            Path = txtPath.Text
        Catch ex As Exception

        End Try
    End Sub

    Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOK.Click
        Try
            'Kiem Tra Duong Dan
            If Not IO.Directory.Exists(txtPath.Text) Then
                MessageBox.Show("Đường dẫn lưu tập tin không đúng. Vui lòng kiểm tra lại", "Thông báo", MessageBoxButtons.OK)
                Exit Sub
                'Kiểm Tồn Tại Tập Tin
            ElseIf IO.File.Exists(txtPath.Text & "\" & txtFile.Text & lblFileType.Text) Then
                DevComponents.DotNetBar.MessageBoxEx.Show("Tên tập tin  đã có trong thư mục.Vui lòng sử dụng tên khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning)
                Exit Sub
            Else
                Result = True
                Path = txtPath.Text
                FileName = txtFile.Text
                FileType = lblFileType.Text
                Me.Close()
            End If
        Catch ex As Exception

        End Try
    End Sub

    Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
        Try
            Result = False
            Me.Close()
        Catch ex As Exception

        End Try
    End Sub
End Class